home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Image Encoders and Decoders / Converting a BMP Image to a PNG Image / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2002-02-15  |  965 b   |  49 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Memo1: TMemo;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24. uses GDIPAPI, GDIPOBJ, GDIPUTIL;
  25.  
  26. {$R *.dfm}
  27.  
  28. procedure TForm1.Button1Click(Sender: TObject);
  29. var
  30.   encoderClsid: TGUID;
  31.   stat: TStatus;
  32.   Image: TGPImage;
  33. begin
  34.    Image := TGPImage.Create('..\..\Media\GrapeBunch.bmp');
  35.  
  36.    // Get the CLSID of the PNG encoder.
  37.    GetEncoderClsid('image/png', encoderClsid);
  38.    stat := image.Save('GrapeBunch.png', encoderClsid, nil);
  39.  
  40.    if(stat = Ok) then
  41.       memo1.Lines.Add('GrapeBunch.png was saved successfully')
  42.    else
  43.       memo1.Lines.Add(format('Failure: stat = %s', [GetStatus(stat)]));
  44.  
  45.     image.Free;
  46. end;
  47.  
  48. end.
  49.